A Complete Introduction To Time Series Analysis (with R):: Classical Decomposition Model part II

In the last article, we introduced the classical decomposition model, and had a comprehensive discussion of trend estimation, notably using the moving average filter. This time, we will discuss the final missing part: seasonality.
Estimating Seasonality
Assume that Yt is some White Noise process, and consider the classical decomposition model


The equations above are just mathematical formalizations of the notion that the process “kind of behaves similarly” every certain period or season. For instance, you can expect winter to start roughly at the same time every year (even in Canada, where we have winter 8 months a year). How can we estimate this seasonal component? Suppose we have some series

Suppose also, that these data have some seasonal function with a period d. We let k=1,..,d be an index ranging over each season. In order to estimate the seasonal component, we follow the next procedure:








The following table might be helpful for visualization for 12 observations and four seasons:

Classical Decomposition Analysis
Now that we are equipped with the tools to estimate seasonality, let’s jump right to the classical decomposition analysis , that is, the procedure to follow to analyze any time series, assuming a classical decomposition.


2. Estimate the seasonal component using the procedure presented before, and obtain deseasonalized data dt.


Hopefully, the resulting Yt-tilde should look like white noise, which tells us that our analysis was correct. Let’s see a full-worked example!
How to R
First, load all the required libraries:













